<template>
    <view class="gjl-view">
        <view class="main">
            <view class="haibao-box">
                <image :show-menu-by-longpress="true" :src="imgsrc" mode=""></image>
            </view>
            <view class="tip-box">
                请长按保存图片至相册，自行打印
            </view>
        </view>
        <mSetimg ref="setimg" :canvasWH="canvasWH"></mSetimg>
    </view>
</template>

<script>
    import mSetimg from '@/components/m-setimg/m-setimg.vue'
    export default {
        components: {
            mSetimg
        },
        data() {
            return {
                imgList: [],
                imgsrc: '',
                canvasWH: {
                    width: 607,
                    height: 1079
                },
                token: ''
            }
        },
        onLoad(item) {
            uni.getStorage({
                key: 'token',
                success: (res)=> {
                    this.token = res.data
                    this.haibaostr()
                }
            });
        },
        methods: {
            haibaostr() {
                setTimeout(() => {
                    let ImgData = {
                        imgList: [{
                            u: 'https://img.thumbrary.com/copartner-page3.png',
                            x: 0,
                            y: 0,
                            h: 1079,
                            w: 607
                        },
                        {
                            u: `https://xcxapi.thumbrary.com/xcxapi/share?token=${this.token}`,
                            x: 206,
                            y: 730,
                            h: 220,
                            w: 220
                        }],
                        textList: []
                    }
                    this.$refs.setimg.haibao(ImgData, (res) => {
                        this.imgsrc = res;
                    })
                }, 200)
            },
        }
    }
</script>

<style scoped lang="scss">
    .gjl-view{
        height: 100%;
    }
    .main{
        box-sizing: border-box;
        height: 100%;
        width: 100%;
        padding: 37rpx 72rpx 0;
    }
    .tip-box{
        text-align: center;
        margin-top: 21rpx;
        font-size:28rpx;
        font-weight:400;
        color:rgba(153,153,153,1);
    }
    .haibao-box{
        height: 1079rpx;
        width: 607rpx;
        image{
            height: 100%;
            width: 100%;
        }
    }
</style>
